package com.hissy.common;

import java.io.IOException;
import java.util.List;
import java.util.Map;

import freemarker.core.Environment;
import freemarker.template.TemplateDirectiveBody;
import freemarker.template.TemplateDirectiveModel;
import freemarker.template.TemplateException;
import freemarker.template.TemplateMethodModelEx;
import freemarker.template.TemplateModel;
import freemarker.template.TemplateModelException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * Created by zhangyanfei on 2018/9/5.
 * 自定义标签 资源标签
 *
 * @author zhangyanfei
 * @date 2018/09/05
 */
public class ResourceDirective implements TemplateDirectiveModel {
    private static final String VARIABLE_RES_ROLES = "_resRolesMap";

    private static final Logger logger = LoggerFactory.getLogger(ResourceDirective.class);

    /**
     * 自定义标签（编程的方式）
     * 控制按钮的显示
     *
     * @param environment           同一个ftl共有
     * @param map                   标签参数
     * @param templateModels
     * @param templateDirectiveBody
     * @throws TemplateException
     * @throws IOException
     */
    @Override
    public void execute(Environment environment, Map map, TemplateModel[] templateModels,
                        TemplateDirectiveBody templateDirectiveBody) throws TemplateException, IOException {
        /**
         * 1.获取用户角色对应的 资源列表
         * 2.查看用户是否拥有当前资源权限
         */
    }
}
